package com.changli01.lambda;

import org.junit.Test;
import org.w3c.dom.ls.LSOutput;

import java.util.Comparator;

public class LambdaTest {
    @Test
    public void test() {
        Runnable r1 = new Runnable() {
            public void run (){
                System.out.println(" I love Java");

            }
        };
        r1.run();


        //Lambda表达式
        //*********************************
        Runnable r2 = ()->{
            System.out.println("Hello World");
        };
        r2.run();

    }
    @Test
    public void test2() {
        //Lambda表达式
        Comparator<Integer> com1 = (i1,i2)->Integer.compare(i1,i2);
        int compare1 = com1.compare(2, 1);
        System.out.println(compare1);

        //方法引用
        Comparator<Integer> com2 = Integer::compare;
        int compare2 = com2.compare(2, 1);
        System.out.println(compare2);


    }

}
